<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>函数颗粒化</title>
</head>
<body>
  <script>
    let tags = 'div,p,ul,h1,h2'.split(',')

    function makeMap(keys) {
      let set = {}
      keys.forEach(item => set[item] = true)
      return function (tagName) {
        return !! set[tagName.toLowerCase()]
      }
    }
    let isHTMlTag = makeMap(tags)
    console.log(isHTMlTag('div'))
  </script>
</body>
</html>